load("@rules_apple//apple:ios.bzl", "ios_unit_test")
load("@rules_cc//cc:defs.bzl", "objc_library")
load(
    "@rules_swift//swift:swift.bzl",
    "swift_library",
)
load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS", "WARNING_FLAGS")

objc_library(
    name = "ios_tests_objc_srcs",
    srcs = glob(
        [
            "*.h",
            "*.m",
        ],
        exclude = [
            "MLNMapViewContentInsetTests.m",
        ],
    ),
    deps = [
        "//platform:ios-sdk",
        "//platform/darwin:test_utility",
    ],
)

objc_library(
    name = "ios_tests_objcpp_srcs",
    srcs = glob(
        [
            "*.mm",
            "*.h",
        ],
    ),
    copts = CPP_FLAGS + MAPLIBRE_FLAGS + WARNING_FLAGS["ios"],
    deps = [
        "//platform:ios-sdk",
    ],
)

swift_library(
    name = "ios_tests_swift_srcs",
    testonly = True,
    srcs = glob(["*.swift"]) + [
        "//platform/darwin:test/MLNSDKTestHelpers.swift",
    ],
    deps = [
        "//platform:ios-sdk",
    ],
)

ios_unit_test(
    name = "ios_test",
    timeout = "long",
    minimum_os_version = "12.0",
    runner = "@rules_apple//apple/testing/default_runner:ios_xctestrun_ordered_runner",
    visibility = [
        "@rules_xcodeproj//xcodeproj:generated",
    ],
    deps = [
        "ios_tests_objc_srcs",
        "ios_tests_objcpp_srcs",
        "ios_tests_swift_srcs",
        "//platform/darwin:darwin_objc_hdrs",
        "//platform/darwin:darwin_objcpp_hdrs",
        "//platform/darwin:shared_tests_objc_srcs",
        "//platform/darwin:shared_tests_objcpp_srcs",
        "//platform/darwin:shared_tests_swift_srcs",
    ],
)

exports_files([
    "Info.plist",
])
